package demo;


import cn.hutool.core.bean.BeanUtil;

import java.lang.reflect.Constructor;
import java.util.List;

/**
 * @author : feixiang.li
 * @since : 2025-04-10 16:27
 */

public class MyTest2 {

    public static class Person {
        private String name;

        public Person(String name) {
            this.name = name;
        }


        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public void introduce() {
            System.out.println("Hello, I'm " + name);
        }
    }

    public static String build(int i) {
        StringBuilder sb = new StringBuilder();
        for (int j = 0; j < i; j++) {
            sb.append("*");
        }
        return sb.toString();
    }

    public static void main(String[] args) {
        try {
            // 使用Constructor.newInstance()创建对象
            Constructor<Person> constructor = Person.class.getConstructor(String.class);
            Person person = constructor.newInstance("Charlie");
            person.introduce(); // 输出: Hello, I'm Charlie
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
